package com.trainsmart.example.demo.control
{
	import com.trainsmart.smartmvc.Context;
	import com.trainsmart.smartmvc.IControl;
	import com.trainsmart.smartmvc.IModel;
	
	import mx.controls.DataGrid;
	
	public class RefreshDG implements IControl
	{
		private var _context:Context = null;
		public function RefreshDG(context:Context)
		{
			_context = context;
		}		
		public function execute(request:Object=null, response:Function=null):void{
			refreshDG();
		}
		/**
		 * step2: query All vo 
		 */ 
		private function refreshDG():void{
			var model:IModel = _context.getModel("userdao");
			model.findByProperties(new Array(),feedInDg);
		}
		/**
		 * step3: show vo data in DataGrid
		 */ 
		private function feedInDg(users:Array):void{
			var list:DataGrid = _context.getInSession("dg") as DataGrid;
			list.dataProvider = users;
		}
	}
}